package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:char(11);unique;comment:用户名"`
	Password string `gorm:"type:char(32);comment:密码"`
}
type RealName struct {
	gorm.Model
	UserId   int64  `gorm:"type:int(11);comment:用户id"`
	RealName string `gorm:"type:char(3);not null;comment:姓名"`
	IdCord   string `gorm:"type:char(18);not null;comment:身份证"`
	Status   int64  `gorm:"type:tinyint(1);default:1;comment:状态:1:拒绝,2:通过"`
}

func (u *User) Create() error {
	return Db.Create(&u).Error
}
func (u *User) UserInfo(username string) error {
	return Db.Where("username = ?", username).Limit(1).Find(&u).Error
}

func (r *RealName) Create() error {
	return Db.Create(&r).Error
}
func (r *RealName) RealNameGet(userId int64, realName string) error {
	return Db.Where("user_id = ? or real_name = ?", userId, realName).Limit(1).Find(&r).Error
}
func (r *RealName) UpdateStatus(realId, Status int64) error {
	return Db.Model(&RealName{}).Where("id = ?", realId).Update("status", Status).Limit(1).Find(&r).Error
}
